package cn.jcet.mapreduce.index;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @author 鲜磊
 * @Date 2021/1/2 22:48
 */
public class IndexTwoMapper extends Mapper<LongWritable,Text,Text,Text> {

    private Text k = new Text();
    private Text v = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //  获取一行
        String line = value.toString();
        // 对数据进行切割
        String[] world = line.split("--");
        // 设置key和value数据
        k.set(world[0]);
        v.set(world[1]);
        context.write(k,v);
    }
}
